<?php

namespace App\Http\Controllers\Common;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class ZanController extends Controller
{
    public function click(Request $request){


        $model = (new CommentController())->pj_model($request);

        if($zan = $model->isZan(auth()->user())){

            $zan->delete();

        }else{

            $model->zan()->create(['user_id'=>auth()->id()]);
        }

        if($request->ajax()){

            return ['code'=>'0','zan_num'=>(new CommentController())->pj_model($request)->zan_num];

        }
        return back();
    }
}
